<!DOCTYPE html>
<html>
  <head>
    <title>审判执行</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
  </head>
  <body style="height:100%">
    <h1>地图</h1><div style="width: 900px;height: 600px;" class="map_show" id="map_show"></div>  
  </body>
</html>

<script src="js/jquery/jquery-2.1.1-min.js"  type="text/javascript"></script>   
<script type="text/javascript"  src="resourse/echarts.min.js"></script>
<script type="text/javascript"  src="resourse/china.js"></script>
<script src="resourse/layer/layer.js"></script>
<script>

var mapcolor = {"spzxyycolor":["#bbf0f0","#AEEEEE","#89e5e5","#57dada","#2cc8c8","#00CDCD","#219696","#008B8B","#008080","#166464","#2F4F4F"]};
var mapchooseColor = mapcolor.spzxyycolor;
generateMap("D00","月报","2020","2月");
function generateMap(fybm,type,year,timeDimension) {
	$.ajax({
		 type: 'POST',
		 url: '/report/getMapData?fybm='+fybm+'&type='+type+'&year='+year+'&timeDimension='+timeDimension,
		 async:false,
		 success: function(res) {
			 var allMapData = eval("("+res.data+")");/*将接口数据string转为json*/
			 picLoad(fybm,allMapData);
		 },
		 error: function(error) {
			 // console.log(error);
			 layer.alert(error, {icon: 5,title: "提示"});
		 }
	});
};
function picLoad(fybm,allMapData){
	$.ajax({
        type : 'POST',
        url : '/report/loadpic',
        data : {
            "data1" :getMapStream(fybm,allMapData,'裁判文书公开指数'),
			"data2" :getMapStream(fybm,allMapData,'庭审直播公开指数')
        },
        contentType : "application/x-www-form-urlencoded",
        success : function(data) {
        	
        }
    });
}

function getMapStream(fybm, allMapData, title) {
	for (var i = 0; i < allMapData.length; i++) {
		var mapdata = allMapData[i];
		if(mapdata.zsmc==title){
			var dom = document.getElementById("map_show");
			var myChart = echarts.init(dom);
			myChart.clear();
			var app = {};
			option = null;
			var uploadedDataURL = 'json/' + fybm + '.geoJson';
			var data1;
			var data = [];
			var maximum = Number(mapdata.maxmin_data[0].max);
			var minimum = Number(mapdata.maxmin_data[0].min);
			var resultname;
			var resultvalue;

			for (var i = 0; i < mapdata.map_data.length; i++) {
				data1 = {};//重点
				var resultname = mapdata.map_data[i].region;

				data1.name = resultname;
				data1.value = Number(mapdata.map_data[i].result);
				data[i] = data1;
			}
			var chart;
			$.get(uploadedDataURL, function(as) {
				echarts.registerMap('FuJian', as);
				option = {
					title : {
						subtext : mapdata.title,
						x : 'center',
						subtextStyle : {
							color : "#c0c0c0",
							fontSize : 18,
						},
					},
					legend : { //地图上面的点
						orient : 'vertical',
						right : '70',
						data : [ '福建' ]
					},
					tooltip : { //提示框组件。
						trigger : 'item', //数据项图形触发，主要在散点图，饼图等无类目轴的图表中使用。
						formatter : '{b}: {c}',
						textStyle : {
							fontSize : '24px'
						}
					},
					visualMap : {
						min : minimum,
						max : maximum,
						text : [ '高', '低' ],
						left : '82%',
						realtime : false,
						inRange : {
							color : [ mapchooseColor[0], mapchooseColor[1],
									mapchooseColor[2], mapchooseColor[3],
									mapchooseColor[4], mapchooseColor[5],
									mapchooseColor[6], mapchooseColor[7],
									mapchooseColor[8], mapchooseColor[9],
									mapchooseColor[10] ]
						// color: ['#edfbfb', '#40a9ed', '#3598c1', '#215096', ]
						},
						textStyle : {
							color : '#fff'
						}
					},

					//backgroundColor : 'rgb(7,19,43,1)',
					series : [ {
						type : 'map',
						zoom : 1.1,
						map : 'FuJian',
						// zlevel: 0,
						label : {
							normal : {
								show : true
							}
						},
						itemStyle : {
							emphasis : {
								areaColor : '#fff464'
							}
						},
						data : data
					} ]
				};
				if (option && typeof option === "object") {
			        myChart.setOption(option, true);
			    }
				
			});
			return myChart.getDataURL();
		}
	}
	
}
</script>
